using BlazorApp1.RfidSdk;

namespace BlazorApp1;

public class RfidRspNotify: RfidReaderRspNotify
{
    public Action<string>? Action;
    
    public void OnRecvResetRsp(RfidReader reader, byte result)
    {

    }

    public void OnRecvSetFactorySettingRsp(RfidReader reader, byte result)
    {

    }

    public void OnRecvStartInventoryRsp(RfidReader reader, byte result)
    {

    }

    public void OnRecvStopInventoryRsp(RfidReader reader, byte result)
    {

    }

    public void OnRecvDeviceInfoRsp(RfidReader reader, byte[] firmwareVersion, byte deviceType)
    {

    }

    public void OnRecvSetWorkParamRsp(RfidReader reader, byte result)
    {

    }

    public void OnRecvQueryWorkParamRsp(RfidReader reader, byte result, RfidWorkParam workParam)
    {

    }

    public void OnRecvSetTransmissionParamRsp(RfidReader reader, byte result)
    {

    }

    public void OnRecvQueryTransmissionParamRsp(RfidReader reader, byte result, RfidTransmissionParam transmissiomParam)
    {

    }

    public void OnRecvSetAdvanceParamRsp(RfidReader reader, byte result)
    {

    }

    public void OnRecvQueryAdvanceParamRsp(RfidReader reader, byte result, RfidAdvanceParam advanceParam)
    {

    }

    public void OnRecvTagNotify(RfidReader reader, TlvValueItem[] tlvItems, byte tlvCount)
    {
        string tagId ="";
        if (null == tlvItems)
        {
            return;
        }
        if (tlvItems.Length < tlvCount)
        {
            return;
        }
        
        for (var index = 0; index < tlvCount;index++)
        {
            switch(tlvItems[index]._tlvType)
            {
                case (byte)RfidSdk.Tlv_Attr_Code.TLV_ATTR_CODE_EPC:
                    for (var tagIndex = 0; tagIndex < tlvItems[index]._tlvLen; tagIndex++)
                    {
                        tagId += tlvItems[index]._tlvValue[tagIndex].ToString("X2");
                    }
                    break;
            }
        }

        if (Action != null) Action(tagId);
    }

    public void OnRecvHeartBeats(RfidReader reader, TlvValueItem[] tlvItems, byte tlvCount)
    {

    }

    public void OnRecvSettingSingleParam(RfidReader reader, byte result)
    {

    }

    public void OnRecvQuerySingleParam(RfidReader reader, TlvValueItem item)
    {

    }

    public void OnRecvWriteTagRsp(RfidReader reader, byte result)
    {

    }

    public void OnRecvRecordNotify(RfidReader reader, string time, string tagId)
    {

    }

    public void OnRecvRecordStatusRsp(RfidReader reader, byte result)
    {

    }

    public void OnRecvSetRtcTimeStatusRsp(RfidReader reader, byte result)
    {

    }

    public void OnRecvQueryRtcTimeRsp(int year, int month, int day, int hour, int min, int sec)
    {

    }

    public void OnRecvReadBlockRsp(RfidReader reader, byte result, byte[] read_data, byte[] epc_data)
    {

    }

    public void OnRecvWriteWiegandNumberRsp(RfidReader reader, byte result)
    {

    }
}